
#include <mockcpp/mockcpp.hpp>
#include <testngpp/testngpp.hpp>

#include <sstream>
#include <iostream>
using namespace std;

#include <Length.h>
#include <ExportLengthUnit.h>
#include <Format.h>
#include <OutputBaseUnit.h>
#include <OutputCascade.h>

USING_MOCKCPP_NS
USING_TESTNGPP_NS

FIXTURE(Length)
{
	TEST(should be able to compare feets w/ yards )
        {
		ASSERT_EQ(Length(3,FEET), Length(1,YARD));
	}
	TEST(should be able to compare feets w/ miles )
        {
		ASSERT_EQ(Length(5280, FEET), Length(1,MILE));
	}
	TEST(should be able to compare feets w/ inchs )
        {
		ASSERT_EQ(Length(1, FEET), Length(12,INCH));
	}

	TEST(should be able to compare miles w/ yards )
        {
		ASSERT_EQ(Length(1, MILE), Length(1760, YARD));
	}
	TEST(should be able to compare miles w/ inchs )
        {
		ASSERT_EQ(Length(1, MILE), Length(1760*3*12, INCH));
	}
	TEST(should be able to compare yards w/ inchs )
        {
		ASSERT_EQ(Length(1, YARD), Length(3*12, INCH));
	}
	TEST(should be able to add yards and inchs )
        {
		ASSERT_EQ(Length(1, YARD) + Length(1, INCH), Length(37, INCH));
	}
	TEST(should be able to add yards and mile )
        {
		ASSERT_EQ(Length(1, MILE) + Length(1, YARD), Length(1761, YARD));
	}
	TEST(should be able to add INCH and mile )
        {
		ASSERT_EQ(Length(1, MILE) + Length(1, INCH), Length(1760*3*12 + 1, INCH));
	}

        TEST(should be able to show length in format)
        {
                Length len(37, INCH);
                stringstream sio;
                sio << Format(len, &OutputCascade());
                ASSERT_EQ(sio.str(), string("1 YARD 1 INCH"));
        }
        TEST(should be able to show length(YARD) in cascade format)
        {
                Length len(1760*3*12 + 3*12, INCH);
                stringstream sio;
                sio << Format(len, & OutputCascade() );
                ASSERT_EQ(sio.str(), string("1 MILE 1 YARD"));
        }

        TEST(should be able to show length in format)
        {
                Length len(1760*3*12 + 3*12, INCH);
                stringstream sio;
                sio << Format(len, &OutputCascade());
                ASSERT_EQ(sio.str(), string("1 MILE 1 YARD"));
        }
        TEST(should be able to show length(INCH) in base format)
        {
                Length len( 3*12, INCH);
                stringstream sio;
                sio << Format(len, &OutputBaseUnit() );
                ASSERT_EQ(sio.str(), string("36 INCH"));
        }
        TEST(should be able to show length(FEET) in base format)
        {
                Length len( 1, FEET);
                stringstream sio;
                sio << Format(len, &OutputBaseUnit() );
                ASSERT_EQ(sio.str(), string("12 INCH"));
        }
        TEST(should be able to show length(YARD) in base format)
        {
                Length len( 1, YARD);
                stringstream sio;
                sio << Format(len, &OutputBaseUnit() );
                ASSERT_EQ(sio.str(), string("36 INCH"));
        }
        TEST(should be able to show length(MILE) in base format)
        {
                Length len( 1, MILE);                
                stringstream sio;
                sio << Format(len, &OutputBaseUnit());
                ASSERT_EQ(sio.str(), string("63360 INCH"));
        }
};
